home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / fsp-2.7 / fsp-2 / fsp / clients / fcatcmd.c next >
Encoding:
C/C++ Source or Header  |  1993-05-03  |  1.6 KB  |  69 lines

  1.     /*********************************************************************\
  2.     *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  3.     *                                                                     *
  4.     *  You may copy or modify this file in any manner you wish, provided  *
  5.     *  that this notice is always included, and that you hold the author  *
  6.     *  harmless for any loss or damage resulting from the installation or *
  7.     *  use of this software.                                              *
  8.     \*********************************************************************/
  9.  
  10. #include "tweak.h"
  11. #include "client_def.h"
  12. #include "c_extern.h"
  13. #include "bsd_extern.h"
  14.  
  15. static  int     optletter;
  16. extern  int     optind;
  17.  
  18. static void dont_die PROTO1(int, signum)
  19. {
  20. }
  21.      
  22. static int get_file PROTO4(char *, path, struct stat *, sbufp, int, mode, int, level)
  23. {
  24.   util_download(path,stdout,0);
  25. }
  26.  
  27. static int rec PROTO3 (char *, name, struct stat *, sbufp, u_long *, mode)
  28. {
  29.     if (*mode != RECURSIVE) return (-1);
  30.     return (0);
  31. }
  32.  
  33. int main PROTO3(int, argc, char **, argv, char **, envp)
  34. {
  35.   char **av, *av2[2];
  36.   int mode;
  37.  
  38.   env_client();
  39.   
  40.   signal(SIGPIPE,dont_die);
  41.   if(isatty(1)) client_trace = 0;
  42.  
  43. /* Parse options
  44.  * -r   recursively show files 
  45.  */
  46.   while ((optletter=getopt(argc, argv,"r")) != EOF)
  47.    switch (optletter)
  48.    {
  49.     case 'r':       
  50.     mode=RECURSIVE;
  51.         break;
  52.    }
  53.  
  54.   argv+=(optind-1);
  55.  
  56.   while(*++argv) {
  57.     if(!(av = glob(*argv))) {
  58.       av = av2;
  59.       av2[0] = *argv; 
  60.       av2[1] = 0;
  61.     }
  62.     while(*av) util_process_file(*av++, mode, get_file, rec, 0L, 0);
  63.   }
  64.   
  65.   client_done();
  66.   
  67.   exit(0);
  68. }
  69.